package pl.edu.agh.gronoMining.frequentSubgraphFinder.frequentSearcher.subgraph.impl;

import java.util.HashMap;
import java.util.Map;

import pl.edu.agh.gronoMining.frequentSubgraphFinder.frequentSearcher.subgraph.DFSCode;

/**
 * Marker that is used to mark edges by StartNodeSubgraph. EdgeMarker can be absolute or not.
 * Absolute means that marked edge is always frequent or unfrequent. If marker is not absolute,
 * markers depends on dfs code of current graph. 
 */
public class EdgeMarker {

	private boolean isAbsolutelyMarked = false;
	
	private boolean isFrequent;
	
	private Map<DFSCode, Boolean> dfsMakersMap = new HashMap<DFSCode, Boolean>();
	
	
	public EdgeMarker() {
	}
	
	public void markAbsolute(boolean isFrequent) {
		this.isAbsolutelyMarked = true;
		this.isFrequent = isFrequent;
	}
	
	public boolean isAbsoluteMarked() {
		return this.isAbsolutelyMarked;
	}
	
	public Boolean isAbsoluteFrequent() {
		if (! this.isAbsolutelyMarked)
			return null;
		return this.isFrequent;
	}
	
	public Boolean getMarkerForDfs(DFSCode dfs) {
		return this.dfsMakersMap.get(dfs);
	}
	
	public void addMarkerForDfs(DFSCode dfs, boolean isFrequent) {
		this.dfsMakersMap.put(dfs, isFrequent);
	}
	
	public String toString() {
		return "marker - absolute: "+this.isAbsolutelyMarked;
	}
}
